package com.stylefeng.guns.rest.modular.wz.api.back;

import com.stylefeng.guns.rest.common.base.controller.ApiBaseController;
import com.stylefeng.guns.rest.common.persistence.dao.*;
import com.stylefeng.guns.rest.modular.auth.util.JwtTokenUtil;
import com.stylefeng.guns.rest.modular.wz.cache.CacheService;
import com.stylefeng.guns.rest.modular.wz.controller.AsyncService;
import com.stylefeng.guns.rest.modular.wz.service.impl.WzAdvServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 新闻模块
 */
@RestController
@RequestMapping("/wz/api/v2/news/")
public class WzNewsV2Api extends ApiBaseController {
    @Autowired
    private WzNewsMapper newsMapper;
    @Autowired
    private WzUserAdvCollectionMapper userAdvCollectionMapper;
    @Autowired
    private WzAdvCommentMapper advCommentMapper;
    @Autowired
    private JwtTokenUtil jwtTokenUtil;
    @Autowired
    private WzUserMapper userMapper;
    @Autowired
    private PfReportMapper reportMapper;
    @Autowired
    private WzAdvServiceImpl advService;
    @Autowired
    private CacheService cacheService;
    @Autowired
    private WzNewsUninterestedMapper newsUninterestedMapper;
    @Autowired
    private WzNewsCommentLikeMapper newsCommentLikeMapper;
    @Autowired
    private WzRedpacketCommentMapper redpacketCommentMapper;
    @Autowired
    private PfFileMapper pfFileMapper;
    @Autowired
    private AsyncService asyncService;
    @Autowired
    private WzAdvMapper advMapper;
    @Autowired
    private SysUserMapper sysUserMapper;
    @Autowired
    private WzAdvMapMapper advMapMapper;

    /**
     * 新闻列表
     */
//    @PostMapping("list")
//    public Res list(@RequestBody ParamMap paramMap){
//        int pageNum = paramMap.getIntMisValid("pageNum");
//        int pageSize = paramMap.getIntMisValid("pageSize");
//        String search = paramMap.getStr("search");
//        Long userCode = paramMap.getLong("userCode");
//        String iosVersion = paramMap.getStr("iosVersion");
//        String androidVersion = paramMap.getStrValid("androidVersion");
//        EntityWrapper<WzNews> entityWrapper = new EntityWrapper<>();
//        if(!StringUtils.isBlankStr(search)){
//            entityWrapper.like("title",search);
//        }
//        Map<String,Object> sys = cacheService.commomSys("commomSys");
//        String sql = "read_number As readNumber,avatar_url As avatarUrl,nick_name As nickName,user_code As userCode,subtype,is_interested As isInterested,is_enlarge as isEnlarge,adv_id As advId,title,cover_url As coverUrl,clicks_number As clicksNumber,create_time As releaseTime";
//        if(sys.get("ios_status").toString().equals("0") && sys.get("ios_check_version").toString().equals(iosVersion)){//判断是否在苹果审核状态
//            entityWrapper.setSqlSelect(sql).in("status",new Integer[]{EnWzAdv.STATUS_RELEASE_no.getIndex(),EnWzAdv.STATUS_RELEASE_yes.getIndex()}).eq("is_show",1).orderBy("release_time",false);
//        }else{
//            boolean rr = false;
//            if(!StringUtils.isBlankStr(iosVersion)){
//                int ios = Integer.parseInt(iosVersion.substring(0,1))*100 + Integer.parseInt(iosVersion.substring(2,3))*10 + Integer.parseInt(iosVersion.substring(4,5));
//                if(ios >= Integer.parseInt(Consts.iosVersion)){
//                    rr = true;
//                }
//            }
//            if(!StringUtils.isBlankStr(androidVersion)){
//                int a = Integer.parseInt(androidVersion);
//                if(a >= Integer.parseInt(Consts.androidVersion)){
//                    rr = true;
//                }
//            }
//            if(rr){
//                entityWrapper.setSqlSelect(sql).in("subtype",new Integer[]{EnWzAdv.SUBTYPE_user_news.getIndex(),EnWzAdv.SUBTYPE_NEWS.getIndex()}).in("status",new Integer[]{EnWzAdv.STATUS_RELEASE_no.getIndex(),EnWzAdv.STATUS_RELEASE_yes.getIndex()}).orderBy("sort",false).orderBy("release_time",false);
//            }else{
//                entityWrapper.setSqlSelect(sql).eq("subtype",EnWzAdv.SUBTYPE_NEWS.getIndex()).in("status",new Integer[]{EnWzAdv.STATUS_RELEASE_no.getIndex(),EnWzAdv.STATUS_RELEASE_yes.getIndex()}).orderBy("release_time",false);
//            }
//        }
//        List<Map<String,Object>>  news = newsMapper.selectMapsPage(new Page<>(pageNum,pageSize),entityWrapper);
//        for(Map<String,Object> map:news){
//            if(Integer.parseInt(map.get("readNumber").toString()) < Integer.parseInt(Consts.newsReadLimit)){
//                map.put("readNumber",0);
//            }
//        }
//        if(userCode != null){
//            for(Map<String,Object> map:news){
//                int c = newsUninterestedMapper.selectCount(new EntityWrapper<WzNewsUninterested>().eq("user_code",userCode).eq("adv_id",map.get("advId")));
//                if(c > 0){
//                    map.put("isInterested",0);
//                }
//            }
//        }
//        return Res.success(paramMap.data(news));
//    }
//
//    /**
//     * 新闻不敢兴趣
//     */
//    @Transactional
//    @PostMapping("uninterested")
//    public Res uninterested(@RequestBody ParamMap paramMap){
//        String advId = paramMap.getStrMisValid("advId");
//        Long userCode = jwtTokenUtil.getUserCodeFromToken();
//        int c = newsUninterestedMapper.selectCount(new EntityWrapper<WzNewsUninterested>().eq("user_code",userCode).eq("adv_id",advId));
//        if(c <= 0){
//            WzNewsUninterested newsUninterested = new WzNewsUninterested();
//            newsUninterested.setAdvId(advId);
//            newsUninterested.setUserCode(userCode.toString());
//            newsUninterested.setCreateTime(new Date());
//            int r = newsUninterestedMapper.insert(newsUninterested);
//            if(r > 0){
//                WzNews news = newsMapper.selectById(advId);
//                news.setUninterestedQuantity(news.getUninterestedQuantity() + 1);
//                r = newsMapper.updateById(news);
//                if(r > 0 ){
//                    return Res.success();
//                }
//            }
//        }else{
//            return Res.fail(BizExceptionEnum.RES_ChongFu.getCode(),"已经不感兴趣!");
//        }
//        return Res.fail();
//    }
//
//    /**
//     * 新闻评论列表
//     */
//    @PostMapping("commentList")
//    public Res commentList(@RequestBody ParamMap paramMap){
//        int pageNum = paramMap.getIntMisValid("pageNum");
//        int pageSize = paramMap.getIntMisValid("pageSize");
//        Long advId = paramMap.getLongMisValid("advId");
//        Long userCode = paramMap.getLong("userCode");
//        String advCommentsSql = "has_user_comment As hasUserComment,is_like As isLike,like_number As likeNumber,adv_comment_id As advCommentId,user_code As userCode,content,nick_name As nickName,avatar_url As avatarUrl,create_time As createTime";
//        List<Map<String,Object>>  advComments = advCommentMapper.selectMapsPage(new Page<>(pageNum,pageSize),new EntityWrapper<WzAdvComment>().setSqlSelect(advCommentsSql).eq("adv_id",advId).orderBy("create_time",false));
//        if(userCode != null){
//            for(Map<String,Object> map:advComments){
//                int c = newsCommentLikeMapper.selectCount(new EntityWrapper<WzNewsCommentLike>().eq("adv_comment_id",Long.parseLong(map.get("advCommentId").toString())).eq("user_code",userCode));
//                if(c > 0){
//                    map.put("isLike",1);
//                }
//                int cc = advCommentMapper.selectCount(new EntityWrapper<WzAdvComment>().eq("adv_id",advId).eq("user_code",Long.parseLong(map.get("userCode").toString())).orNew("reply_user_code={0}", Long.parseLong(map.get("userCode").toString())).eq("adv_id",advId));
//                if(cc > 1){
//                    map.put("hasUserComment",1);
//                }
//            }
//        }
//        return Res.success(paramMap.data(advComments));
//    }
//
//    /**
//     * 评论点赞
//     */
//    @PostMapping("commentLike")
//    @Transactional
//    public Res commentLike(@RequestBody ParamMap paramMap){
//        String advId = paramMap.getStrMisValid("advId");
//        String advCommentId = paramMap.getStrMisValid("advCommentId");
//        Long userCode = jwtTokenUtil.getUserCodeFromToken();
//        int c = newsCommentLikeMapper.selectCount(new EntityWrapper<WzNewsCommentLike>().eq("adv_comment_id",advCommentId).eq("user_code",userCode));
//        if(c <= 0){
//            WzAdvComment advComment = advCommentMapper.selectById(advCommentId);
//            advComment.setLikeNumber(advComment.getLikeNumber()  + 1);
//            WzNewsCommentLike newsCommentLike = new WzNewsCommentLike();
//            newsCommentLike.setAdvId(advId);
//            newsCommentLike.setAdvCommentId(advCommentId);
//            newsCommentLike.setUserCode(userCode.toString());
//            newsCommentLike.setCreateTime(new Date());
//            int r = advCommentMapper.updateById(advComment);
//            if(r > 0){
//                r = newsCommentLikeMapper.insert(newsCommentLike);
//                if(r > 0){
//                    return Res.success();
//                }
//            }
//        }else{
//            return Res.fail(BizExceptionEnum.RES_ChongFu.getCode(),"已经点赞");
//        }
//        return Res.fail("已经点赞！");
//    }
//
//    /**
//     * 评论取消点赞
//     */
//    @Transactional
//    @PostMapping("cancleCommentLike")
//    public Res cancleCommentLike(@RequestBody ParamMap paramMap){
//        Long advId = paramMap.getLongMisValid("advId");
//        Long advCommentId = paramMap.getLongMisValid("advCommentId");
//        Long userCode = jwtTokenUtil.getUserCodeFromToken();
//        int c = newsCommentLikeMapper.selectCount(new EntityWrapper<WzNewsCommentLike>().eq("adv_id",advId).eq("user_code",userCode));
//        if(c > 0){
//            WzAdvComment advComment = advCommentMapper.selectById(advCommentId);
//            advComment.setLikeNumber(advComment.getLikeNumber() - 1);
//            if(advComment.getLikeNumber() < 0){
//                advComment.setLikeNumber(0);
//            }
//            int r = advCommentMapper.updateById(advComment);
//            if(r > 0){
//                r = newsCommentLikeMapper.delete(new EntityWrapper<WzNewsCommentLike>().eq("adv_id",advId).eq("user_code",userCode));
//                if(r > 0){
//                    return Res.success();
//                }
//            }
//        }else{
//            return Res.fail(BizExceptionEnum.RES_ChongFu.getCode(),"已经取消点赞");
//        }
//        return Res.fail();
//    }
//
//    /**
//     * 用户对话列表
//     */
//    @Transactional
//    @PostMapping("userCommentList")
//    public Res userCommentList(@RequestBody ParamMap paramMap){
//        int pageNum = paramMap.getIntMisValid("pageNum");
//        int pageSize = paramMap.getIntMisValid("pageSize");
//        Long advId = paramMap.getLongMisValid("advId");
//        Long userCode = paramMap.getLongMisValid("userCode");
//        Long targetUserCode = paramMap.getLongMisValid("targetUserCode");
//        String advCommentsSql = "is_like As isLike,like_number As likeNumber,adv_comment_id As advCommentId,user_code As userCode,content,nick_name As nickName,avatar_url As avatarUrl,create_time As createTime";
//        List<Map<String,Object>>  advComments = advCommentMapper.selectMapsPage(new Page<>(pageNum,pageSize),new EntityWrapper<WzAdvComment>().setSqlSelect(advCommentsSql).eq("adv_id",advId).eq("user_code",targetUserCode).orNew("reply_user_code={0}", targetUserCode).eq("adv_id",advId).orderBy("create_time",true));
//        if(userCode != null){
//            for(Map<String,Object> map:advComments){
//                int c = newsCommentLikeMapper.selectCount(new EntityWrapper<WzNewsCommentLike>().eq("adv_comment_id",Long.parseLong(map.get("advCommentId").toString())).eq("user_code",userCode));
//                if(c > 0){
//                    map.put("isLike",1);
//                }
//            }
//        }
//        return Res.success(paramMap.data(advComments));
//    }
//
//    /**
//     * 评论投诉
//     */
//    @PostMapping("report")
//    public Res report(@RequestBody ParamMap paramMap) throws  Exception{
//        Long advCommentId = null;
//        Long advId = null;
//        int reportType = paramMap.getIntMisValid("reportType");
//        int type = paramMap.getIntMisValid("type");
//        if(type == EnPfFile.REPORT_TYPE_AdvMap.getIndex()){
//            return Res.success();
//        }
//        if(type == EnPfFile.REPORT_TYPE_newsComment.getIndex()){
//            advCommentId = paramMap.getLongMisValid("advCommentId");
//        }else if(type == EnPfFile.REPORT_TYPE_news.getIndex()){
//            advId = paramMap.getLongMisValid("advId");
//        }else if(type == EnPfFile.REPORT_TYPE_Redpacket.getIndex() || type == EnPfFile.REPORT_TYPE_Adv_Comment.getIndex() || type == EnPfFile.REPORT_TYPE_AdvMap_Comment.getIndex()){
//            advCommentId = paramMap.getLongMisValid("advCommentId");
//        }
//        Long userCode = paramMap.getLong("userCode");
//        PfReport report = new PfReport();
//        report.setCreateTime(new Date());
//        report.setReportType(reportType);
//        String con = "";
//        if(reportType == 1){
//            con = "广告骚扰";
//        }else if(reportType == 2){
//            con = "低俗、辱骂";
//        }else if(reportType == 3){
//            con = "色情";
//        }else if(reportType == 4){
//            con = "反动、血腥暴力";
//        }else if(reportType == 5){
//            con = "违法（套现、危险品等）";
//        }
//        String pushContent = "尊敬的用户，您的一个爆料评论被举报，举报原因:"+con;
//        String pushTitle = "您的一个爆料评论被举报!";
//        if(type == EnPfFile.REPORT_TYPE_newsComment.getIndex()){
//            report.setTargetId(advCommentId);
//            report.setRemark("新闻评论举报:评论id:"+advCommentId+",举报人id:"+userCode+"举报类型:"+con);
//        }else if(type == EnPfFile.REPORT_TYPE_news.getIndex()){
//            report.setTargetId(advId);
//            report.setRemark("新闻举报:新闻id:"+advId+",举报人id:"+userCode+"举报类型:"+con);
//        }else if(type == EnPfFile.REPORT_TYPE_Redpacket.getIndex()){
//            report.setTargetId(advCommentId);
//            report.setRemark("红包评论举报:红包评论id:"+advCommentId+",举报人id:"+userCode+"举报类型:"+con);
//            pushContent = "尊敬的用户，您的一个红包评论被举报，举报原因:"+con;
//            pushTitle = "您的一个红包评论被举报!";
//        }else if(type == EnPfFile.REPORT_TYPE_Adv_Comment.getIndex()){
//            report.setTargetId(advCommentId);
//            report.setRemark("广告评论举报:广告评论id:"+advCommentId+",举报人id:"+userCode+"举报类型:"+con);
//            pushContent = "尊敬的用户，您的一个广告评论被举报，举报原因:"+con;
//            pushTitle = "您的一个广告评论被举报!";
//        }else if(type == EnPfFile.REPORT_TYPE_AdvMap.getIndex()){
//            report.setTargetId(advCommentId);
//            report.setRemark("地图信息举报:地图信息id:"+advCommentId+",举报人id:"+userCode+"举报类型:"+con);
//            pushContent = "尊敬的用户，您的一个地图信息被举报，举报原因:"+con;
//            pushTitle = "您的一个地图信息被举报!";
//        }else if(type == EnPfFile.REPORT_TYPE_AdvMap_Comment.getIndex()){
//            report.setTargetId(advCommentId);
//            report.setRemark("地图信息评论被举报:地图信息id:"+advCommentId+",举报人id:"+userCode+"举报类型:"+con);
//            pushContent = "尊敬的用户，您的一个地图信息评论被举报，举报原因:"+con;
//            pushTitle = "您的一个地图信息评论被举报!";
//        }
//        report.setType(EnPfFile.REPORT_TYPE_newsComment.getIndex());
//        report.setType(type);
//        if(userCode != null){
//            report.setUserCode(userCode);
//        }
//        int r = reportMapper.insert(report);
//        if(type == EnPfFile.REPORT_TYPE_newsComment.getIndex()){//新闻评论
//            WzAdvComment advComment = advCommentMapper.selectById(advCommentId);
//            if(advComment == null){
//                return Res.fail(BizExceptionEnum.NEWS_SHIXIAO);
//            }
//            WzUser user = cacheService.user(advComment.getUserCode());
//            //异步发送结果
//            WzUserMessage userMessage = new WzUserMessage();//用户消息
//            userMessage.setCreateTime(new Date());
//            userMessage.setType(EnWz.User_Message_News_Comment.getIndex());//新闻评论推送
//            userMessage.setUserCode(advComment.getUserCode());
//            userMessage.setContent(pushContent);
//            userMessage.setTitle(pushTitle);
//            //发送通知
//            JSONObject j = new JSONObject();
//            j.put("advId", advComment.getAdvId());
//            asyncService.checkUserAdv(userMessage,user,EnWz.User_Message_News_Comment.getIndex(),j);
//        }
//        if(type == EnPfFile.REPORT_TYPE_Redpacket.getIndex() || type == EnPfFile.REPORT_TYPE_AdvMap_Comment.getIndex()){//红包评论 地图信息评论
//            WzRedpacketComment redpacketComment = redpacketCommentMapper.selectById(advCommentId);
//            if(redpacketComment == null){
//                return Res.fail(BizExceptionEnum.NEWS_SHIXIAO);
//            }
//            WzUser user = cacheService.user(redpacketComment.getUserCode());
//            //异步发送结果
//            WzUserMessage userMessage = new WzUserMessage();//用户消息
//            userMessage.setCreateTime(new Date());
//            if(type == EnPfFile.REPORT_TYPE_AdvMap_Comment.getIndex()){
//                userMessage.setType(EnWzUser.Message_Type_AdvMap_Comment.getIndex());//周边评论相关
//            }else {
//                userMessage.setType(EnWzUser.Message_Type_AdvMap_Comment.getIndex());//红包评论
//            }
//            userMessage.setJumpTarget(redpacketComment.getAdvId().toString());
//            userMessage.setUserCode(redpacketComment.getUserCode());
//            userMessage.setContent(pushContent);
//            userMessage.setTitle(pushTitle);
//            //发送通知
//            JSONObject j = new JSONObject();
//            j.put("advId", redpacketComment.getAdvId());
//            j.put("subtype", redpacketComment.getType());
//            asyncService.checkUserAdv(userMessage,user,EnWz.User_Message_RedPacket_Comment.getIndex(),j);
//
//            WzUser sysWzUser = cacheService.user(userCode);
//            List<SysUser> sysUser = sysUserMapper.selectList(new EntityWrapper<SysUser>().eq("phone",sysWzUser.getAccount()));
//            if(sysUser.size() > 0){
//                redpacketComment.setStatus(EnWz.Report_Status_check.getIndex());
//                redpacketCommentMapper.updateById(redpacketComment);
//            }
//        }
//        if(type == EnPfFile.REPORT_TYPE_Adv_Comment.getIndex()){//广告评论
//            WzRedpacketComment redpacketComment = redpacketCommentMapper.selectById(advCommentId);
//            if(redpacketComment == null){
//                return Res.fail(BizExceptionEnum.NEWS_SHIXIAO);
//            }
//            WzUser user = cacheService.user(redpacketComment.getUserCode());
//            //异步发送结果
//            WzUserMessage userMessage = new WzUserMessage();//用户消息
//            userMessage.setCreateTime(new Date());
//            userMessage.setType(EnWzUser.Message_Type_Adv_Comment.getIndex());
//            userMessage.setJumpTarget(redpacketComment.getAdvId().toString());
//            userMessage.setUserCode(redpacketComment.getUserCode());
//            userMessage.setContent(pushContent);
//            userMessage.setTitle(pushTitle);
//            //发送通知
//            JSONObject j = new JSONObject();
//            j.put("advId", redpacketComment.getAdvId());
//            j.put("subtype", 1);
//            asyncService.checkUserAdv(userMessage,user,EnWz.User_Message_Adv_Comment.getIndex(),j);
//
//            WzUser sysWzUser = cacheService.user(userCode);
//            List<SysUser> sysUser = sysUserMapper.selectList(new EntityWrapper<SysUser>().eq("phone",sysWzUser.getAccount()));
//            if(sysUser.size() > 0){
//                redpacketComment.setStatus(EnWz.Report_Status_check.getIndex());
//                redpacketCommentMapper.updateById(redpacketComment);
//            }
//        }
//
//        if(type == EnPfFile.REPORT_TYPE_Redpacket.getIndex() || type == EnPfFile.REPORT_TYPE_Adv_Comment.getIndex() || type == EnPfFile.REPORT_TYPE_AdvMap_Comment.getIndex()){//红包评论
//            WzRedpacketComment redpacketComment = redpacketCommentMapper.selectById(advCommentId);
//            WzAdv adv = advMapper.selectById(redpacketComment.getAdvId());
//            if(adv == null){
//                WzAdvMap advMap = advMapMapper.selectById(redpacketComment.getAdvId());
//                userCode = advMap.getUserCode();
//            }else{
//                userCode = adv.getUserCode();
//            }
//            if(userCode.toString().equals(userCode.toString())){
//                redpacketComment.setStatus(EnWz.Report_Status_check.getIndex());
//                redpacketCommentMapper.updateById(redpacketComment);
//            }
//        }
//        if(type == EnPfFile.REPORT_TYPE_newsComment.getIndex()){//新闻评论
//            WzUser user = cacheService.user(userCode);
//            List<SysUser> sysUser = sysUserMapper.selectList(new EntityWrapper<SysUser>().eq("phone",user.getAccount()));
//            if(sysUser.size() > 0){
//                WzAdvComment advComment = advCommentMapper.selectById(advCommentId);
//                advComment.setStatus(EnWz.Report_Status_check.getIndex());
//                advCommentMapper.updateById(advComment);
//            }
//        }
//         if(r > 0){
//            return Res.success();
//        }
//        return Res.fail();
//    }
//
//    /**
//     * 用户新闻提交审核
//     */
//    @PostMapping("checkNews")
//    public Res checkNews(@RequestBody ParamMap paramMap) throws Exception{
//        String title = paramMap.getStrMisValid("title");
//        String advDetail = paramMap.getStrValid("advDetail");
//        String coverUrl = paramMap.getStrMisValid("coverUrl");
//        Long advId = paramMap.getLongValid("advId");//新闻id
//        WzNews news = new WzNews();
//        if(StringUtils.isNotBlank(advDetail)){
//            news.setHasDetail(1);
//            news.setAdvDetail(advDetail);
//        }else{
//            news.setHasDetail(0);
//            news.setAdvDetail("");
//        }
//        Long userCode = jwtTokenUtil.getUserCodeFromToken();
//        WzUser user = cacheService.user(userCode);
//        if(advId == null){
//            advId = IdWorker.getId();
//        }
//        news.setAdvId(advId);
//        news.setUserCode(userCode);
//        news.setNickName(user.getNickName());
//        news.setAvatarUrl(user.getAvatarUrl());
//        news.setTitle(title);
//        news.setCoverUrl(coverUrl);
//        news.setPublishingType(3);
//        news.setStatus(EnWzAdv.STATUS_WaitCheck.getIndex());
//        news.setCreateTime(new Date());
//        news.setIsShow(0);
//        news.setSubtype(EnWzAdv.SUBTYPE_user_news.getIndex());
//        news.setReleaseTime(new Date());
//        int r = newsMapper.insert(news);
//        if(r > 0){
//            if(Consts.dev.equals("false")){
//                String[] a = new String[]{"15206121566","17751585858","13775148808","18551098600","13861129809"};
//                for(String c:a){
//                    SendSmsResponse response = AliyunSmsUtil.sendAdminSms(c,"有新的爆料需要审核", Consts.ADMIN_TEMPLATE_CODE);
//                }
//            }
//            return Res.success();
//        }
//        return Res.fail();
//    }
//
//    /**
//     * 用户新闻重新提交审核
//     */
//    @PostMapping("resubmitCheckNews")
//    public Res resubmitCheckNews(@RequestBody ParamMap paramMap) throws Exception{
//        Long advId = paramMap.getLongMisValid("advId");
//        String title = paramMap.getStrMisValid("title");
//        String advDetail = paramMap.getStrValid("advDetail");
//        String coverUrl = paramMap.getStrMisValid("coverUrl");
//        WzNews news = newsMapper.selectById(advId);
//        if(StringUtils.isNotBlank(advDetail)){
//            news.setHasDetail(1);
//            news.setAdvDetail(advDetail);
//        }else{
//            news.setHasDetail(0);
//            news.setAdvDetail("");
//        }
//        Long userCode = jwtTokenUtil.getUserCodeFromToken();
//        WzUser user = cacheService.user(userCode);
//        news.setUserCode(userCode);
//        news.setNickName(user.getNickName());
//        news.setAvatarUrl(user.getAvatarUrl());
//        news.setTitle(title);
//        news.setCoverUrl(coverUrl);
//        news.setStatus(EnWzAdv.STATUS_WaitCheck.getIndex());
//        news.setSubtype(EnWzAdv.SUBTYPE_user_news.getIndex());
//        int r = newsMapper.updateById(news);
//        if(r > 0){
//            if(Consts.dev.equals("false")){
//                String[] a = new String[]{"15206121566","17751585858","13775148808","18551098600","13861129809"};
//                for(String c:a){
//                    SendSmsResponse response = AliyunSmsUtil.sendAdminSms(c,"有新的爆料需要审核", Consts.ADMIN_TEMPLATE_CODE);
//                }
//            }
//            return Res.success();
//        }
//        return Res.fail();
//    }
//
//    /**
//     * 删除新闻
//     */
//    @PostMapping("del")
//    public Res del(@RequestBody ParamMap paramMap){
//        Long advId = paramMap.getLongMisValid("advId");
//        Long userCode = jwtTokenUtil.getUserCodeFromToken();
//        WzNews news = newsMapper.selectById(advId);
//        if(userCode.toString().equals(news.getUserCode().toString())){
//            int r = newsMapper.deleteById(advId);
//            if(r > 0){
//                r = pfFileMapper.delete(new EntityWrapper<PfFile>().eq("target_id",news.getAdvId().toString()));
//                return Res.success();
//            }
//        }
//        return Res.fail();
//    }
//
//    /**
//     * 用户新闻发布记录
//     */
//    @PostMapping("record")
//    public Res advRecord(@RequestBody ParamMap paramMap){
//        int pageNum = paramMap.getIntMisValid("pageNum");
//        int pageSize = paramMap.getIntMisValid("pageSize");
//        Long userCode = jwtTokenUtil.getUserCodeFromToken();
//        //业务处理
//        String sql = "status,subtype,adv_id As advId,title,cover_url As coverUrl,clicks_number As clicksNumber,release_time As releaseTime,collection_number As collectionNumber,like_number As likeNumber";
//        List<Map<String,Object>>  news = newsMapper.selectMapsPage(new Page<>(pageNum,pageSize), new EntityWrapper<WzNews>().setSqlSelect(sql).eq("user_code",userCode).orderBy("create_time",false));
//        return Res.success(paramMap.data(news));
//    }
}
